﻿<UserControl x:Class="Dotnet.Samples.Silverlight.Gui"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             d:DesignWidth="1280"
             d:DesignHeight="800">
    <Grid x:Name="RootGrid" Width="Auto" Height="Auto">
        <Grid x:Name="ContainerGrid" Width="800"  Height="600">
            <Grid.RowDefinitions>
                <RowDefinition x:Name="ContainerGridUpperRow" Height="*" />
                <RowDefinition x:Name="ContainerGridLowerRow" Height="Auto" />
            </Grid.RowDefinitions>
            <sdk:DataGrid Grid.Row="0" x:Name="BooksDataGrid" DataContext="books" AutoGenerateColumns="False" CanUserReorderColumns="True" CanUserResizeColumns="True" CanUserSortColumns="True" IsReadOnly="False" Width="Auto" Height="Auto" Margin="8">
                <!-- TODO: Improve width management -->
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn x:Name="BooksDataGridIsbnColumn" Header="ISBN" Binding="{Binding Isbn}" Width="100" IsReadOnly="True" />
                    <sdk:DataGridTextColumn x:Name="BooksDataGridTitleColumn" Header="Title" Binding="{Binding Title}" Width="150" IsReadOnly="True" />
                    <!--
                        <sdk:DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="TextWrapping" Value="Wrap"/>
                            </Style>
                        </sdk:DataGridTextColumn.ElementStyle>
                    </sdk:DataGridTextColumn>
                    -->
                    <sdk:DataGridTextColumn  x:Name="BooksDataGridAuthorColumn" Header="Author" Binding="{Binding Author}" Width="150" IsReadOnly="True" />
                    <sdk:DataGridTextColumn  x:Name="BooksDataGridPublisherColumn" Header="Publisher" Binding="{Binding Publisher}" Width="150" IsReadOnly="True" />
                    <sdk:DataGridTemplateColumn  x:Name="BooksDataGridPublishedColumn" Header="Published" Width="100" SortMemberPath="Published" IsReadOnly="True" >
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:DatePicker IsEnabled="False" UseLayoutRounding="True" SelectedDate="{Binding Published}" SelectedDateFormat="Short" />
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTextColumn x:Name="BooksDataGridPagesColumn" Header="Pages" Binding="{Binding Pages}" Width="55" IsReadOnly="True" />
                    <sdk:DataGridCheckBoxColumn x:Name="BooksDataGridInStockColumn" Header="In Stock" Binding="{Binding InStock}" Width="*" IsReadOnly="False" />
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
            <Grid x:Name="BookDetailsGrid" Grid.Row="1" DataContext="{Binding SelectedItem, ElementName=BooksDataGrid}" Width="Auto" Height="Auto" Margin="0,8,0,8" ShowGridLines="True">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition x:Name="BookDetailsLeftColumn" Width="*" />
                    <ColumnDefinition x:Name="BookDetailsRightColumn" Width="*" />
                </Grid.ColumnDefinitions>
                <Grid Grid.Column="0" Margin="0,8,0,8" ShowGridLines="True">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Column="0" Grid.Row="0" x:Name="BookDetailsGridIsbnTextBlock" Width="Auto" VerticalAlignment="Center" MinHeight="16" MaxHeight="16" Margin="8" Text="ISBN" />
                    <TextBox Grid.Column="1" Grid.Row="0"  x:Name="BookDetailsGridIsbnTextBox" Width="Auto" MinHeight="24" MaxHeight="24" Margin="8" Text="{Binding Isbn}" />
                    <TextBlock Grid.Column="0" Grid.Row="1" x:Name="BookDetailsGridTitleTextBlock" Width="Auto" VerticalAlignment="Center" MinHeight="16" MaxHeight="16" Margin="8" Text="Title" />
                    <TextBox Grid.Column="1" Grid.Row="1" x:Name="BookDetailsGridTitleTextBox" Width="Auto" MinHeight="24" MaxHeight="24" Margin="8" Text="{Binding Title}" />
                    <TextBlock Grid.Column="0" Grid.Row="2" x:Name="BookDetailsGridAuthorTextBlock" Width="Auto" VerticalAlignment="Center" MinHeight="16" MaxHeight="16" Margin="8" Text="Author" />
                    <TextBox Grid.Column="1" Grid.Row="2" x:Name="BookDetailsGridAuthorTextBox" Width="Auto" MinHeight="24" MaxHeight="24" Margin="8" Text="{Binding Author}" />
                </Grid>
                <Grid Grid.Column="1"  Margin="8,8,0,8" ShowGridLines="True">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Column="0" Grid.Row="0" x:Name="BookDetailsGridPublisherTextBlock" Width="Auto" VerticalAlignment="Center" MinHeight="16" MaxHeight="16" Margin="8" Text="Publisher" />
                    <TextBox Grid.Column="1" Grid.Row="0" x:Name="BookDetailsGridPublisherTextBox" Width="Auto" MinHeight="24" MaxHeight="24" Margin="8" Text="{Binding Publisher}" />
                    <TextBlock Grid.Column="0" Grid.Row="1" x:Name="BookDetailsGridPublishedTextBlock" Width="Auto" VerticalAlignment="Center" MinHeight="16" MaxHeight="16" Margin="8" Text="Published" />
                    <TextBox Grid.Column="1" Grid.Row="1" x:Name="BookDetailsGridPublishedTextBox" Width="Auto" MinHeight="24" MaxHeight="24" Margin="8" Text="{Binding Published, StringFormat='f'}" />
                    <TextBlock Grid.Column="0" Grid.Row="2" x:Name="BookDetailsGridPagesTextBlock" Width="Auto" VerticalAlignment="Center" MinHeight="16" MaxHeight="16" Margin="8" Text="Pages" />
                    <TextBox Grid.Column="1" Grid.Row="2" x:Name="BookDetailsGridPagesTextBox" Width="Auto" MinHeight="24" MaxHeight="24" Margin="8" Text="{Binding Pages}" />
                </Grid>
            </Grid>
        </Grid>
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="LightSkyBlue" Offset="0" />
                <GradientStop Color="White" Offset="1" />
            </LinearGradientBrush>
        </Grid.Background>
    </Grid>
</UserControl>